/**
 * @file
 * @description 权限模块接口文件
 */
import request from './request'

/**
 * @method
 * @description 获取所有菜单
 */
export const getMenus = () => request.get('menus')

/**
 * @method
 * @description 获取角色列表
 */
export const getRoles = () => request.get('roles')

/**
 * @method
 * @description 修改角色
 * @param {Nbumber} id 当前用户ID 
 * @param {Number} rid 当前角色id 
 */
export const updateRole = (id, rid) => request.put(`users/${id}/role`, { rid })

/**
 * @method
 * @description 添加角色
 * @param {Object} model 要添加的角色对象
 */
export const addRole = (model) => request.post('roles', model)

/**
 * @method
 * @description 修改角色
 * @param {Object} model 要修改的角色对象
 */
export const modifyRole = (model) => request.put(`roles/${model.id}`, model)

/**
 * @method
 * @description 删除角色
 * @param {Number} id 要删除的角色ID
 */

export const deleteRole = (id) => request.delete(`roles/${id}`)


/**
 * @method
 * @description 获取菜单树形数据
 */
export const getMenuTree = () => request.get('rights/tree')

/**
 * @method
 * @description 分配权限
 * @param {Number} id 要修改的角色ID 
 * @param {Srting} rids 要添加的菜单ID
 */
export const assignRights = (id, rids) => request.post(`roles/${id}/rights`, { rids })
